(function (G) {
  window["components_Svg_Dom"]({
  "component": true,
  "usingComponents": {}
},{
template:'#TEMPLATE_components_Svg_Dom',

    options: {
      multipleSlots: true
    },
    props: {
      src:{
        type:String
      }
    },
    data: function () {
      return {
        id:'svg' + G.zIndex(),
        dom:null,
        domRect:null,
        svg:null
      }
    },
    methods: {
      getRect(dom){
        let domRect = G.getBoundingClientRect(dom)
        return {
          width:domRect.width,
          height:domRect.height,
          left:domRect.left - this.domRect.left,
          top:domRect.top - this.domRect.top
        }
      },
      //echats专用
      echartInit(id){
        var element = this.dom.querySelector('#' + id)
        let rect = this.getRect(element)
        let canvas = G.creatElement('div',{
          style:{
            position:'absolute',
            width:rect.width + 'px',
            height:rect.height + 'px',
            marginLeft:rect.left + 'px',
            marginTop:rect.top + 'px',
            background:'#fff'
          }
        })
        this.dom.insertBefore(canvas,this.svg)
        arguments[0] = canvas
        return echarts.init.apply(null,arguments)
      },
      load(replaces){
        return new Promise(next => {
          G.ajax(this.src,res => {
            if(replaces && Array instanceof replaces){
              for(let i = 0; i < replaces.length; i ++){
                res = res.replace(new RegExp(replaces[i][0],replaces[i][2]),replaces[i][1])
              }
            }
            this.dom = document.querySelector('#' + this.id)
            this.dom.innerHTML = res
            this.domRect = G.getBoundingClientRect(this.dom)
            this.svg = this.dom.childNodes[0]
            next(this.svg)
          },{
            dataType:'text'
          })
        })
      }
    }
  })
})(Y)